<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./cdn/docsearch.css">
    <script src="./cdn/docsearch.js"></script>
    <!-- <script src="https://cdn.jsdelivr.net/npm/algoliasearch@4/dist/algoliasearch.umd.min.js"></script>
    <script src="https://cdn.jsdelivr.net/autocomplete.js/0/autocomplete.min.js"></script>
     <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script> -->
    <!-- <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script> -->

    <link rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/docsearch.js/dist/cdn/docsearch.min.css" />

    <!-- Before the closing </body> -->
    <script src="https://cdn.jsdelivr.net/npm/docsearch.js/dist/cdn/docsearch.min.js"></script>
</head>

<body>
    111
    <input id="algolia-search-input" type="text">


    <script>
        // $(function () {
            // const client = algoliasearch('BF4RDO0EYD', '4a2857c7afb83b2687a2922aaaf56bcf');
            // const index = client.initIndex('juphoon');
            console.log(docsearch)
            let algoliaConfig = {
                appId: 'BF4RDO0EYD',
                apiKey: 'd02d64058b08646fc04cf361671ec59c',
                indexName: 'juphoon',
                algoliaOptions: {
                    hitsPerPage: 6,
                    removeWordsIfNoResults: 'allOptional'
                }
            }
            // docsearch(
            //     Object.assign({}, userOptions, {
            //         inputSelector: "#algolia-search-input",
            //         // #697 Make docsearch work well at i18n mode.
            //         algoliaOptions: Object.assign(
            //             {
            //                 facetFilters: [`lang:${lang}`].concat(
            //                     algoliaOptions.facetFilters || []
            //                 ),
            //             },
            //             algoliaConfig
            //         ),
            //         handleSelected: (input, event, suggestion) => {
            //             const { pathname, hash } = new URL(suggestion.url);
            //             const routepath = pathname.replace(this.$site.base, "/");
            //             const _hash = decodeURIComponent(hash);
            //             this.$router.push(`${routepath}${_hash}`);
            //         },
            //     }))
            docsearch({
                // Your apiKey and indexName will be given to you once
                // we create your config
                apiKey: 'd02d64058b08646fc04cf361671ec59c',
                indexName: 'juphoon',
                appId: 'BF4RDO0EYD', // Should be only included if you are running DocSearch on your own.
                // Replace inputSelector with a CSS selector
                // matching your search input
                inputSelector: '#algolia-search-input',
                // Set debug to true to inspect the dropdown
                debug: false,
            });
            // function newHitsSource(index, params) {
            //     return function doSearch(query, cb) {
            //         index
            //             .search(query, params)
            //             .then(function (res) {
            //                 cb(res.hits, res);
            //             })
            //             .catch(function (err) {
            //                 console.error(err);
            //                 cb([]);
            //             });
            //     };
            // }

            // autocomplete('#algolia-search-input', { hint: false }, [
            //     {
            //         source: newHitsSource(index, { hitsPerPage: 5 }),
            //         templates: {
            //             suggestion: function (suggestion) {
            //                 console.log(suggestion)
            //             }
            //         }
            //     }
            // ]).on('autocomplete:selected', function (event, suggestion, dataset, context) {
            //     console.log(event, suggestion, dataset, context);
            // });

        // })
    </script>
</body>

</html>